//
//  ScrollViewCell.m
//  Tang
//
//  Created by 352324497@qq.com on 15/12/3.
//  Copyright © 2015年 352324497@qq.com. All rights reserved.
//

#import "ScrollViewCell.h"
@implementation ScrollViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        CGFloat height = KWidth * 586 / 900;
        self.scrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, KWidth, height) imagesGroup:nil];
        self.scrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
        self.scrollView.delegate = self;
        self.scrollView.dotColor = [UIColor whiteColor];
        self.scrollView.placeholderImage = [UIImage imageNamed:@"PS"];
        [self.contentView addSubview:_scrollView];
        self.array = [NSMutableArray array];
    }
    return self;
}

-(void)setCellWithArray:(NSMutableArray *)array
{
    if (array.count != 0)
    {
        self.array = array;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            self.scrollView.imageURLStringsGroup = array;
        });
    }
}

#pragma mark - 点击
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
//    NSLog(@"-------- 点击第%ld 张图", index);
//    ScrollViewTableController *scrollViewVc = [[ScrollViewTableController alloc]initWithStyle:(UITableViewStylePlain)];
//    ScrollModel *model = self.array[index];
//    scrollViewVc.extend = model.extend;
//    NSString *str = [scrollViewVc.extend substringToIndex:4];
////    NSLog(@" str === %@", str);
//    if ([str isEqualToString:@"http"])
//    {
//        
//    }
//    else
//    {
//        self
//    }
    if ([self.delegate respondsToSelector:@selector(jumpPageWithIndex:)])
    {
        NSLog(@"-------- 点击第%ld 张图", index);
        [self.delegate jumpPageWithIndex:index];
    }
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
